import request from '@/utils/request'
import axios from 'axios'

// 查询bom资料维护列表
export function listBom(query) {
  return request({
    url: '/project/bom/list',
    method: 'get',
    params: query,
  })
}

// 查询bom资料维护列表
export function bomTree(cusId) {
  return request({
    url: '/project/bom/bomTree/' + cusId,
    method: 'get',
  })
}

// 查询bom资料维护详细
export function getBom(bomId) {
  return request({
    url: '/project/bom/' + bomId,
    method: 'get',
  })
}

// 新增bom资料维护
export function addBom(data) {
  return request({
    url: '/project/bom',
    method: 'post',
    data: data,
  })
}

// 修改bom资料维护
export function updateBom(data) {
  return request({
    url: '/project/bom',
    method: 'put',
    data: data,
  })
}

// 删除bom资料维护
export function delBom(bomId) {
  return request({
    url: '/project/bom/' + bomId,
    method: 'delete',
  })
}

// 导出bom资料维护
export function exportBom(query) {
  return request({
    url: '/project/bom/export',
    method: 'get',
    params: query,
  })
}

//添加孩子节点
export function addChildBom(data) {
  return request({
    url: '/project/bod',
    method: 'post',
    data: data,
  })
}

//通过父项代码获取孩子
export function getChild(data) {
  return request({
    url: '/project/bom/getAllChildByFxdm/' + data,
    method: 'get',
  })
}

export function checkBom(bomIds) {
  return request({
    url: '/project/bom/checkBom/' + bomIds,
    method: 'put',
  })
}

export function RollbackBom(data) {
  return request({
    url: '/project/bom/RollbackBom',
    method: 'put',
    data: data,
  })
}
// /dev-api/hd-api/project/materiel/selectItmByWldm/{wldm}
//匹配生产物料物料代码
export function getItmByWldm(wldm) {
  return request({
    url: '/project/materiel/selectItmByWldm/' + wldm,
    method: 'get',
  })
}
//提交
export function submitBom(bomId) {
  return request({
    url: '/project/bom/submit/ ' + bomId,
    method: 'put',
  })
}

//查询子项
export function findBodById(bodId) {
  return request({
    url: '/project/bod/' + bodId,
    method: 'get',
  })
}

//修改子项
export function editBod(data) {
  return request({
    url: '/project/bod',
    method: 'put',
    data: data,
  })
}

//删除子项
export function deleteBod(bodId) {
  return request({
    url: '/project/bod/' + bodId,
    method: 'delete',
  })
}

//根据客户编码或者物料代码获取对应Bom（有对应关系就能查询出来）
export function getBomByOrders(order) {
  return request({
    url: '/project/bom/getBomByOrders/' + order,
    method: 'get',
  })
}

//判断父项里面是否包含子项 /JudgeParentWithChild
export function JudgeParentWithChild(fxdm, zxdm) {
  return request({
    url: '/project/bod/JudgeParentWithChild/' + fxdm + '/' + zxdm,
    method: 'get',
  })
}

//按照条件查询Bom结构

export function selectByOrders(wldm, type, limit) {
  return request({
    url: '/project/bom/selectByOrders/' + wldm + '/' + type + '/' + limit,
    method: 'get',
  })
}

//判断是否只有一个成型件
export function judge(query1, query2, query3) {
  return request({
    url: '/project/bom/judgeCx/' + query1 + '/' + query2 + '/' + query3,
    method: 'get',
  })
}

// bom父子项导出
export function exportBomParentChild(bomIds) {
  return request({
    url: '/project/bom/exportBomParentChild',
    method: 'get',
    params: {
      bomIds: bomIds,
    },
    responseType: 'blob',
  })
}

// bom拷贝
export function copyBomByParentCode(data) {
  return request({
    url: '/project/bom/copyBom',
    method: 'put',
    data: data,
  })
}
